﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>货位</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
      
            <a title="编辑信息" href="javascript:;" lay-event="wpEdit"><i class="layui-icon">&#xe642;</i></a>
            <a title="删除信息" href="javascript:;" lay-event="wpDel"><i class="layui-icon">&#xe640;</i></a>
        
    </script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                        <input type="hidden" name="wareCode" id="wareCode" />
                    </form>
                    <div class="layui-card-header">

                        @*<button class="layui-btn" id="btn-sync" type="button" onclick="Sync('wareHouse')"><i class="layui-icon">&#xe641;</i>数据同步</button>*@
                        @* <button class="layui-btn" id="userAdd" type="button" onclick="addData()"><i class="layui-icon"></i>新增货位</button>*@

                        <span style="margin-left: 20px; padding: 7px; background-color: #bababa;font-size:Xx-small">数据停用</span>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>

    function loadData() {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
              { field: 'id', title: 'ID', width: 80 } 
                , { field: 'cCode', align: 'center',  title: '货位编码', width: '25%' }
                , { field: 'cName', align: 'center',  title: '货位名称', width: '25%', }
                , { field: 'statusName', align: 'center',  title: '数据状态', width: '25%' }
                , { fixed: 'right', align: 'center',  title: '操作', width: '10%', align: 'center', toolbar: '#barDemo' }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
                $.each(res['data'], function (i, obj) {
                    var status = obj["status"];
                    if (status == "N") {
                        TableRowColor('layui-table-main', i, '#bababa');
                    }
                });
            }
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
            , url: "../Basis/GetDataList?dataType=wp&condition=" + wareCode
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , limits: [10, 15, 20]
            , limit: 10 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data,
                    layEvent=obj.event;
                if (data.barType == "Box") {
                    if (layEvent === 'view') {
                        InfoOpenPage('../Bar/InBoxBars?boxCode=' + data.barCode, data.barCode + "-箱码", "85%", "90%");
                    }
                }
                else if (layEvent == 'wpEdit') {
                    if (data.isSync == "Y") {
                        layer.msg("同步数据禁止修改");
                    } else {
                        InfoOpenPage('../Basis/UpdateWarePosition?dataId=' + data.id, data.cName + "-修改", "65%", "80%");
                    }

                }
                else {
                    if (data.isSync == "Y") {
                        layer.msg("同步数据禁止删除");
                    } else {
                        layer.confirm('确定删除此货位？', function (index) {
                            $.ajax({
                                // url: "../Basis/DelWarePosition",
                                url: "../Basis/DelCommonData",
                                data: { dataId: data.id },
                                type: 'post',
                                success: function (rsl) {
                                    if (rsl.Result) {
                                        layer.msg('删除成功！');
                                    } else {
                                        layer.msg('删除失败！');
                                    }
                                    loadData()
                                }
                            })
                            layer.close('index')
                        })
                    }
                }

            });
        });
    }
    var wareCode = "";
    $(function () {
        wareCode = getUrlVariable("wareCode");
        loadData();
    })

    function addData() {
        InfoOpenPage('../Basis/UpdateWarePosition?dataId=0&parentCode=' + wareCode, '新增货位', '65%', '80%');
    }

</script>